package beautiful.butterfly.drds.binlog.connection;


import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.nio.channels.SocketChannel;

@Slf4j
public class Connection
{
    @Setter
    @Getter
    private SocketChannel socketChannel;
    @Setter
    @Getter
    private ConnectionAttributes connectionAttributes;

    public Connection(SocketChannel socketChannel, ConnectionAttributes connectionAttributes)
    {
        this.socketChannel = socketChannel;
        this.connectionAttributes = connectionAttributes;
    }


    public void close()
    {
        if (null != socketChannel)
        {
            try
            {
                socketChannel.close();
                log.info("close socket: " + socketChannel);
            } catch (IOException e)
            {
            }
            socketChannel = null;
        }

    }
}
